﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace EEM.Models
{
    public partial class EEMContext : DbContext
    {
        public EEMContext()
        {
        }

        public EEMContext(DbContextOptions<EEMContext> options)
            : base(options)
        {
        }

        public virtual DbSet<AreaDatalnfo> AreaDatalnfos { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=localhost;Initial Catalog=Energy_Efficiency_Monitoring;Persist Security Info=True;User ID=sa;PWD=123456");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<AreaDatalnfo>(entity =>
            {
                entity.Property(e => e.Areald).HasComment("区域id");

                entity.Property(e => e.C02density)
                    .HasColumnName("C02Density")
                    .HasComment("二氧化碳");

                entity.Property(e => e.Humidity).HasComment("湿度");

                entity.Property(e => e.InsertTime)
                    .HasColumnType("datetime")
                    .HasComment("插入时间");

                entity.Property(e => e.Temperature)
                    .HasColumnType("decimal(18, 1)")
                    .HasComment("温度");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
